import appSettings from '@/config/app-settings'
import i18n from '@/lang'
import store from '@/store'
import AppConstant from '@/constant/app-constant'

const title = appSettings.title

export default function getPageTitle (key) {
  let loginStyle = store.getters.loginStyle
  const hasKey = i18n.te(`route.${key}`)
  if (hasKey) {
    const pageName = i18n.t(`route.${key}`)
    let name = i18n.t(`common.appName`)
    if (loginStyle === AppConstant.CUSTOM_CRRC ||
        loginStyle === AppConstant.CUSTOM_DAHUA ||
        loginStyle === AppConstant.CUSTOM_MITSUBISHI) {
      name = i18n.t(`common.simpleAppName`)
    } else if (loginStyle === AppConstant.CUSTOM_ONEPLUS) {
      name = i18n.t('common.oneplusAppName')
    }
    const appName = name
    return `${pageName} - ${appName}`
  }
  return `${title}`
}
